#ifndef __SYMBOL_H_
#define __SYMBOL_H_

#include "stdint.h"

#define SYMBOL_NAME_MAX 32

typedef enum _symbol_type symbol_type;
enum _symbol_type
{
    symbol_type_num,                //<! 数字
    symbol_type_plus,               //<! '+'
    symbol_type_increase,           //<! '++'
    symbol_type_minus,              //<! '-'
    symbol_type_decrease,           //<! '--'
    symbol_type_multiply,           //<! '*'
    symbol_type_divide,             //<* '/'
    symbol_type_assign,             //<* '='
    symbol_type_surplus,            //<* '%'
    symbol_type_more,               //<* '>'
    symbol_type_more_equal,         //<* '>='
    symbol_type_less,               //<* '<'
    symbol_type_less_equal,         //<* '<='
    symbol_type_equal,              //<* '=='
    symbol_type_not_equal,          //<* '!='
    symbol_type_not,                //<* '!'
    symbol_type_id,                 //<* 标识符
    symbol_type_open_parenthesis,   //<! '('
    symbol_type_close_parenthesis,  //<! ')'
    symbol_type_open_bracket,       //<! '['
    symbol_type_close_bracket,      //<! ']'
    symbol_type_open_brace,         //<! '{'
    symbol_type_close_brace,        //<! '}'
    symbol_type_apostrophe,         //<! '''
    symbol_type_point,              //<! '.'
    symbol_type_dot,                //<！','
    symbol_type_semicolon,          //<! ';'
    symbol_type_bits_and,           //<! '&'
    symbol_type_and,                //<! '&&'
    symbol_type_bits_or,            //<! '|'
    symbol_type_or,                 //<! '||'
    symbol_type_for,                //<! 关键字"for"
    symbol_type_do,                 //<! 关键字"do"
    symbol_type_while,              //<! 关键字"while"
    symbol_type_break,              //<! 关键字"break"
    symbol_type_continue,           //<! 关键字"continue"
    symbol_type_char,               //<! 关键字"char"
    symbol_type_double,             //<! 关键字"double"
    symbol_type_enum,               //<! 关键字"enum"
    symbol_type_float,              //<! 关键字"float"
    symbol_type_int,                //<! 关键字"int"
    symbol_type_long,               //<! 关键字"long"
    symbol_type_short,              //<! 关键字"short"
    symbol_type_signed,             //<! 关键字"signed"
    symbol_type_struct,             //<! 关键字"struct"
    symbol_type_union,              //<! 关键字"union"
    symbol_type_unsigned,           //<! 关键字"unsigned"
    symbol_type_void,               //<! 关键字"void"
    symbol_type_if,                 //<! 关键字"if"
    symbol_type_else,               //<! 关键字"else"
    symbol_type_goto,               //<! 关键字"goto"
    symbol_type_character,          //<! 单个字符
    symbol_type_string,             //<! 字符串
    symbol_type_switch,             //<! "switch"
    symbol_type_case,               //<! "case"
    symbol_type_default,            //<! "default"
    symbol_type_return,             //<! "return"
    symbol_type_auto,               //<! "auto"
    symbol_type_extern,             //<! "extern"
    symbol_type_register,           //<! "register"
    symbol_type_static,             //<! "static"
    symbol_type_const,              //<! "const"
    symbol_type_sizeof,             //<! "sizeof"
    symbol_type_typedef,            //<! "typedef"
    symbol_type_volatile,           //<! "volatile"
    symbol_type_max, //<* 类型最大值
};

typedef struct _symbol_st symbol_st;
struct _symbol_st
{
    uint32_t type;
    uint64_t value;
    uint8_t name[SYMBOL_NAME_MAX];
};

typedef struct _symbol_list_st symbol_list_st;
struct _symbol_list_st
{
    symbol_st symbol;
    struct _symbol_list_st *list;
};


/**
 * @brief 将symbol type转换为字符串
 *
 * @param type symbol type
 * @return char* symbol type 对应的字符串
 */
char *symbol_type_str(
    uint32_t type);

/**
 * @brief 申请一个symbol
 *
 * @return symbol_st*
 */
symbol_st *symbol_calloc(
    void);

/**
 * @brief 释放symbol_st结构体
 *
 * @param symbol
 */
void symbol_free(
    symbol_st *symbol);

/**
 * @brief symbol 测试函数
 *
 */
void symbol_test(
    void);

#endif
